package com.gxa.service.impl;

import com.gxa.dto.GoodsQueryDto;
import com.gxa.dto.ReturnBillDto;
import com.gxa.dto.ReturnQueryDto;
import com.gxa.mapper.*;
import com.gxa.service.ReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
public class ReturnServiceImpl implements ReturnService {

    @Autowired
    private ReturnMapper returnMapper;

    @Autowired
    private SupplierMapper supplierMapper;

    @Autowired
    private RegionMapper regionMapper;

    @Autowired
    private RepositoryMapper repositoryMapper;

    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public List<ReturnQueryDto> queryAllReturnBill(ReturnBillDto returnBillDto) {
        List<ReturnQueryDto> returnList = returnMapper.queryAllReturnBill(returnBillDto);
        return returnList;
    }


    @Transactional
    @Override
    public void updateStatus(Integer id, Integer status) {
        returnMapper.updateStatus(id,status);
    }

    @Override
    public List merge() {
        List<List> aaa = new ArrayList<>();

        List snList = supplierMapper.querySidAndName();//供应商编号
        List regionList = regionMapper.queryAll();//退货地址
        List rnameList = repositoryMapper.queryRname();//仓库
        List<Integer> typeList = returnMapper.queryReturnType();//退货方式
        List depList = empMapper.queryDepartment();
        List<GoodsQueryDto> goodsList = goodsMapper.queryGoodsList();

        aaa.add(snList);
        aaa.add(regionList);
        aaa.add(rnameList);
        aaa.add(typeList);
        aaa.add(depList);
        aaa.add(goodsList);

        return aaa;
    }

}
